package com.zefu.controller;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.zefu.entity.Dept;
import com.zefu.service.DeptService;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/dept")
public class DeptController {
	@Resource
	private DeptService deptService;

	@RequestMapping(value = "/insert.do", method = RequestMethod.POST)
	public String insert(Dept dept) {
		deptService.insertDept(dept);
		return "/main";
	}

	@RequestMapping(value = "/delete.do", method = RequestMethod.POST)
	public String insert(int deptId) {
		deptService.deleteById(deptId);
		return "/main2";
	}

	@RequestMapping(value = "/update.do", method = RequestMethod.POST)
	public String updateById(Dept dept) {
		deptService.updateById(dept);
		return "/main3";
	}

	@RequestMapping(value = "/select.do", method = RequestMethod.POST)
	@ResponseBody
	public Dept select(int deptId) {
		return deptService.selectDept(deptId);

	}
}
